const glob = require('fast-glob');
const { relative } = require('path');
const Router = require('@koa/router');
const config = require('../config');
const koaRouter = new Router({
  prefix: config.routerPrefix
});
glob.sync('./routes/*.js', { dot: true })
  .filter(value => (value.indexOf('index.js') === -1))
  .map(fouterFile => {
    const routerPath = relative(__dirname, fouterFile);
    const router = require('./' + routerPath);
    router.register(koaRouter);
  });
module.exports = koaRouter;